local PANEl = {}
 
function PANEl:LayoutEntity( Entity )
 
	if ( self.bAnimated ) then -- Make it animate normally
		self:RunAnimation()
	end
 
end
 
vgui.Register("DModelPanelNoRotate",PANEl,"DModelPanel")

local PANEL={}

function PANEL:Init()
	self.Color = Color(40,40,40,150)
	self.OutlineColor = Color(124,124,124,245)
end

function PANEL:SetupModel(Model,item,FOV,CamPos,LookAt)
	
	self.icon = vgui.Create( "DModelPanelNoRotate", self )
	self.icon:SetSize( 50, 50 )
	self.icon:SetCamPos( CamPos )
	self.icon:SetLookAt( LookAt )
	self.icon:SetFOV(FOV)
	self.icon:SetAnimSpeed(0.1)
	self.icon:SetModel(Model)
	self.icon.itemtable = item
	function self.icon:OnCursorEntered( )
		self.inside = true
		self:GetParent().Color = Color(60,60,60,150)
		self.iteminfo = vgui.Create("item_info")
		self.iteminfo:SetSize(100,100)
		self.iteminfo:MakePopup()
		self.iteminfo:RequestFocus()
		self.iteminfo:ItemTable(self.itemtable)
	end

	function self.icon:OnCursorExited( )
		self.inside = false
		self:GetParent().Color = Color(40,40,40,150)
		if self.iteminfo then
			self.iteminfo:Remove()
		end
	end
	
	function self.icon:Think()
		if self.inside then
			local x,y = gui.MousePos( )
			self.iteminfo:SetPos(x + 10,y + 2)
		end
	end
end

 
function PANEL:Paint()
	surface.SetDrawColor(self.OutlineColor)
    self:DrawOutlinedRect()
	surface.SetDrawColor(self.Color)
	surface.DrawRect(0,0,self:GetWide(),self:GetTall());
end

function PANEL:OnCursorExited( )
		self.Color = Color(40,40,40,150)
end

function PANEL:OnCursorEntered( )
	self.Color = Color(60,60,60,150)
end
 
function PANEL:OnMousePressed()

end

function PANEL:OnMouseReleased()

	self.iteminfo:Remove()
end 

function PANEL:ItemInfo(item)

end


 
vgui.Register( "item", PANEL );